# 目录: 文件夹.
# 工作目录,当前目录,父级目录: day17

import os
# print(os.getcwd())  # D:\s23\day17 绝对路径  ***
# os.chdir(r'D:\s23\day9')
# print(os.getcwd())
# print(os.curdir)
# print(os.pardir)

# 和文件夹相关  ***
import os
# os.makedirs('dirname1/dirname2/dirname3/dirname4')  # 多级目录
# os.removedirs('dirname1/dirname2/dirname3/dirname4') # 截止到有文件的那层
# os.mkdir(r'd:\abc') # 单级目录
# os.rmdir('abc')
# print(os.listdir(r'D:\s23\day15'))

#
# os.remove()  删除一个文件  ***
# os.rename("oldname","newname")  重命名文件/目录  ***
# print(os.stat(r'D:\s23\day17\01 昨日内容回顾.py'))

# path 和路径相关  ***
# print(os.path.abspath('04 os模块.py'))  # D:\s23\day17\01 昨日内容回顾.py
# print(os.path.split(os.path.abspath('01 昨日内容回顾.py')))  # ('D:\\s23\\day17', '01 昨日内容回顾.py')
# print(os.path.dirname(r'D:\s23\day9\01 初始函数.py'))  # 获取父级目录
# print(os.path.dirname(os.path.abspath('01 昨日内容回顾.py')))
# print(__file__)  # 动态获取当前文件的绝对路径
# 获取当前文件的爷爷级的目录
# print(os.path.dirname(os.path.dirname(__file__)))
# print(os.path.basename(r'D:\s23\day9\01 初始函数.py'))  # 获取文件名
# print(os.path.exists(r'D:\s23\day9\02 初始函数.py'))
# 判断是否是绝对路径
# print(os.path.isabs(r'D:\s23\day9\01 初始函数.py'))
# print(os.path.isabs(r'day17/01 昨日内容回顾.py'))
# 判断该路径是否是一个文件路径
# print(os.path.isfile(r'D:\s23\day9\01 初始函数.py'))
# print(os.path.isfile(r'D:\s23\day9'))
# print(os.path.isdir(r'D:\s23\day17\dirname1\dirname2'))
# print(os.path.exists(r'D:\s23\day17\dirname1\dirname2'))
# 判断是否是一个目录(文件夹)
# print(os.path.isdir(r'D:\s23\day17\02 序列化模块.py'))
# D:\s23\day16\评论文章
# path = os.path.join('D:','s23','day20','随便')
# print(path)
# par_dir = os.path.dirname(__file__)
# print(par_dir)  # D:/s23/day17
# path = r'D:\s23\day17\db\lydata'
# path = par_dir + '\db' +'\lydata'
# path = os.path.join(par_dir,'db','lydata')
# with open(path,encoding='utf-8',mode='a') as f1:
#     f1.write('李业在红浪漫消费998元')

# print(os.path.getatime('D:\s23\day17\db\lydata'))
# print(os.path.getmtime('D:\s23\day17\db\lydata'))
# print(os.path.getsize('D:\s23\day17\db\lydata'))

# print(os.stat(r'D:\s23\day17\01 昨日内容回顾.py'))